package com.turbo.boot.crawler.controller.admin;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.turbo.boot.crawler.dao.entity.CrawlerResultEntity;
import com.turbo.boot.crawler.service.ICrawlerResultService;
import com.turbo.framework.annatation.TurboRestController;
import com.turbo.starter.base.rest.BaseController;
import com.turbo.starter.mybatis.CrudOption;
import io.swagger.v3.oas.annotations.tags.Tag;

import javax.servlet.http.HttpServletRequest;

/**
 * crawlerResult
 */
@Tag(name = "result", description = "result")
@TurboRestController(value = "/admin/crawler/result", api = {"page", "list"})
public class AdminCrawlerResultController extends BaseController<ICrawlerResultService, CrawlerResultEntity> {


    @Override
    protected void init(HttpServletRequest request, JSONObject requestParams) {
        CrudOption<CrawlerResultEntity> crudOption = createOp()
                .fieldEq("groupId").keyWordLikeFields("quotaCode");
        crudOption.queryWrapper(new QueryWrapper<CrawlerResultEntity>().orderByAsc(crudOption.getField("createdAt")));
        setListOption(crudOption);
        setPageOption(crudOption);
    }
}